home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 February: Tool Chest / Dev.CD Feb 94.toast / New System Software Extensions / QuickDraw™ GX v1.0ß2 / Interfaces & Libraries / interfaces / loader routines.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-29  |  5.2 KB  |  116 lines  |  [TEXT/MPS ]

  1. /* segment loader:
  2.     public interface definition
  3.     by Cary Clark, Georgiann Delaney, Michael Fairman, Dave Good, Robert Johnson, Keith McGreggor, Oliver Steele, David Van Brink, Chris Yerga
  4.     Copyright 1987 - 1991 Apple Computer, Inc.  All rights reserved.    */
  5.  
  6. #ifndef loaderRoutinesIncludes
  7. #define loaderRoutinesIncludes
  8.  
  9.     #ifndef memoryTypesIncludes
  10.         #include "memory types.h"
  11.     #endif
  12.  
  13.     #ifdef appleInternal
  14.         #ifdef insideLoader
  15.             #define GXInlineCode(x)
  16.         #endif
  17.         #ifndef dontBackpatchSegmentLoader
  18.             #define backpatchSegmentLoader
  19.         #endif
  20.     #endif
  21.     #ifndef GXInlineCode
  22.         #ifdef backpatchSegmentLoader
  23.             #define GXInlineCode(x)   = {0x303C, 0x8080 + (x), 0xA832}
  24.         #else
  25.             #define GXInlineCode(x)   = {0x303C, 0x8000 + (x), 0xA832}
  26.         #endif
  27.     #endif
  28.  
  29.     #define endOfLoaderReturnStack    ((void *)0xFFFFFFFF)
  30.  
  31.     typedef enum {
  32.         returnSegmentSize,
  33.         returnSegmentData,
  34.         returnSegmentCount,
  35.         returnTaskReturnStack
  36.     } segmentSpoolTypes;
  37.  
  38.     typedef long segmentSpoolType;
  39.  
  40.     typedef long (*segmentSpoolFunction)(segmentSpoolType callType, long userReference, long segmentNumber,
  41.         long offset, long size, void *destination);
  42.  
  43.     #ifndef insideLoader
  44.         typedef struct privateLoaderClientRecord *loaderClient;
  45.     #endif
  46.  
  47.     #ifdef __cplusplus
  48.     extern "C" {
  49.     #endif
  50.  
  51.     /* the system needs to call this routine before making any other segment loader calls. note that there is no shutdown routine */
  52.     void InitializeLoader(void) GXInlineCode(0);
  53.  
  54.     /* these routines allocate and dispose of loader clients */
  55.     loaderClient NewLoaderClient(void *memoryStart, long memoryLength, segmentSpoolFunction spoolFunc,
  56.         long userReference) GXInlineCode(1);
  57.     void DisposeLoaderClient(loaderClient client) GXInlineCode(2);
  58.  
  59.     /* these routines return the non-modifiable fields of a loaderClient */
  60.     void *GetLoaderClientGlobals(loaderClient client) GXInlineCode(3);
  61.     void *GetLoaderClientGlobalsStart(loaderClient client) GXInlineCode(4);
  62.     gxHeap *GetLoaderClientHeap(loaderClient client) GXInlineCode(5);
  63.  
  64.     /* these routines get and set the modifiable fields of a loaderClient */
  65.     long GetLoaderClientUserReference(loaderClient client) GXInlineCode(6);
  66.     void SetLoaderClientUserReference(loaderClient client, long newRef) GXInlineCode(7);
  67.     segmentSpoolFunction GetLoaderClientSpoolFunction(loaderClient client) GXInlineCode(8);
  68.     void SetLoaderClientSpoolFunction(loaderClient client, segmentSpoolFunction newFunc) GXInlineCode(9);
  69.  
  70.     /* these must be switched at process switch time if several processes are using the loaderClient */
  71.     void *GetLoaderClientReturnStack(loaderClient client) GXInlineCode(10);
  72.     void SetLoaderClientReturnStack(loaderClient client, void *newStack) GXInlineCode(11);
  73.     void *GetLoaderClientLastBlock(loaderClient client) GXInlineCode(12);
  74.     void SetLoaderClientLastBlock(loaderClient client, void *lastBlock) GXInlineCode(13);
  75.  
  76.     /* this routine disposes of all the unlocked segments in the loaderClient’s code gxHeap */
  77.     void FlushLoaderSegments(loaderClient client) GXInlineCode(14);
  78.  
  79.     /* this routine loads the segment that contains the function pointed to by address, locks this segment down and makes
  80.     it permanent by patching the jump table to jump straight into it. this segment can never be moved or disposed of after
  81.     this, since the segment loader no longer has any way of knowing whether some process is currenly executing in it or
  82.     not */
  83.  
  84.     void LoadPermanentSegment(void *address) GXInlineCode(15);
  85.  
  86.     /* this routine aborts all the functions entered in the return stack from its current position back to the passed saveStack
  87.     value. the lockCounts for all these functions will be updated properly and the returnStack and lastBlock will be restored */
  88.  
  89.     void CleanupLoaderReturnStack(loaderClient client, void *savedStack) GXInlineCode(16);
  90.  
  91.     /* these routines lock and unlock access to the loader client’s code gxHeap. the first one also sets the busy counts for code blocks correctly */
  92.     void LockLoaderClientMemory(loaderClient client) GXInlineCode(17);
  93.     void UnlockLoaderClientMemory(loaderClient client) GXInlineCode(18);
  94.  
  95.     /* this routine validates the passed loaderClient to ensure that it is a loaderClient and it hasn’t been damaged */
  96.     void ValidateLoaderClient(loaderClient client) GXInlineCode(19);
  97.  
  98.     /* this returns the size of the patchRecord that Patch and Unpatch LoaderClientFunction use */
  99.     long GetLoaderClientPatchSize(void) GXInlineCode(20);
  100.  
  101.     /* you must call these routines to create and destroy patch records for jump table entries */
  102.     void *PatchLoaderClientFunction(loaderClient client, short functionA5Offset, void *patchAddress) GXInlineCode(21);
  103.     void UnpatchLoaderClientFunction(loaderClient client, void *patchAddress) GXInlineCode(22);
  104.  
  105.     /* once the patch record has been created, these functions allow jump table entries to be redirected */
  106.     void *GetLoaderClientFunction(loaderClient client, short functionA5Offset) GXInlineCode(23);
  107.     void SetLoaderClientFunction(loaderClient client, short functionA5Offset, void *newAddress) GXInlineCode(24);
  108.  
  109.     #ifdef __cplusplus
  110.     }
  111.     #endif
  112.  
  113.     #undef  GXInlineCode
  114.  
  115. #endif
  116.